<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>once</title>
</head>

<body>
    <div id="content">0</div>
    <button id="btn">增加</button>
    <script>
        let count = 0;
        const once = fn => {
            let called = false;
            return function (...args) {
                if (called) {
                    return;
                }
                called = true;
                return fn.apply(this, args);
            }
        }
        const addHandler = (event) => {
            count++;
            document.getElementById('content').textContent = count;
            console.log(event)
        }
        document.getElementById('btn').addEventListener('click',once(addHandler));
    </script>
</body>

</html>